{extend name='extra@admin/content'}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    {if auth("$classuri/add")}
    <button data-modal="{:url('add')}" data-title="添加API应用" class='layui-btn layui-btn-small'><i
            class='fa fa-plus'></i> 添加应用
    </button>
    {/if}
    {if auth("$classuri/forbid")}
    <button data-update data-field='app_status' data-value='0' data-action='{:url("$classuri/forbid")}'
            class='layui-btn layui-btn-small layui-btn-danger'><i
            class='fa fa-ban'></i> 禁用应用
    </button>
    {/if}
    {if auth("$classuri/resume")}
    <button data-update data-field='app_status' data-value='1' data-action='{:url("$classuri/resume")}'
            class='layui-btn layui-btn-small'><i
            class='fa fa-check-circle-o'></i> 启用应用
    </button>
    {/if}
    {if auth("$classuri/del")}
    <button data-update data-field='delete' data-action='{:url("$classuri/del")}'
            class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-close'></i> 删除应用
    </button>
    {/if}
</div>
{/block}

{block name="content"}

<!-- 表单搜索 开始 -->
<form class="animated form-search" action="__SELF__" onsubmit="return false" method="get">

    <div class="row">
        <div class="col-xs-2">
            <div class="form-group">
                <input type="text" name="app_name" value="{$Think.get.app_name|default=''}" placeholder="接口应用名称"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-3">
            <div class="form-group">
                <input type="text" name="app_id" value="{$Think.get.app_id|default=''}" placeholder="接口应用AppId"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <select name="handler" class="input-sm form-control">
                    <option value="">- 操作者 -</option>
                    <!--{foreach $handlers as $key=>$handler}-->
                    <!--{if $Think.get.handler eq $key}-->
                    <option selected value="{$key}">{$handler}</option>
                    <!--{else}-->
                    <option value="{$key}">{$handler}</option>
                    <!--{/if}-->
                    <!--{/foreach}-->
                </select>
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <select name="app_status" class="input-sm form-control">
                    <option value="">- 状态 -</option>
                    <option {if $Think.get.app_status=='1'}selected{/if} value="1">使用中</option>
                    <option {if $Think.get.app_status=='0'}selected{/if} value="0">已禁用</option>
                </select>
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
            </div>
        </div>
    </div>

</form>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="" method="POST">
    <input type="hidden" value="resort" name="action"/>
    <table class="table table-hover">
        <thead>
        <tr>
            <th class='list-table-check-td'>
                <input data-none-auto="" data-check-target='.list-check-box' type='checkbox'/>
            </th>
            <th class='text-center'>应用名称</th>
            <th class='text-center'>AppId</th>
            <th class='text-center'>AppSecret</th>
            <th class='text-center'>应用说明</th>
            <th class='text-center'>创建时间</th>
            <th class='text-center'>修改时间</th>
            <th class='text-center'>应用状态</th>
            <th class='text-center'>操作者</th>
            <th class='text-center'>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='list-table-check-td'>
                <input class="list-check-box" value='{$vo.id}' type='checkbox'/>
            </td>
            <td class='text-center'>{$vo.app_name|default="<span style='color:#ccc'>暂无</span>"}</td>
            <td class='text-center'>{$vo.app_id|default="<span style='color:#ccc'>暂无</span>"}</td>
            <td class='text-center'>{$vo.app_secret|default="<span style='color:#ccc'>暂无</span>"}</td>
            <td class='text-center'>{$vo.app_info|default="<span style='color:#ccc'>暂无</span>"}</td>
            <td class='text-center'>{$vo.create_at|default="<span style='color:#ccc'>暂无</span>"}</td>
            <td class='text-center'>{$vo.update_at|default="<span style='color:#ccc'>暂无</span>"}</td>
            <td class='text-center'>
                {if $vo.app_status eq 1}
                    {if auth("$classuri/forbid")}
                        <a data-update="{$vo.id}" data-field='app_status' data-value='0' data-action='{:url("$classuri/forbid")}'
                           href="javascript:void(0)" style="color:#090">使用中</a>
                    {else}
                        <span style="color:#090">使用中</span>
                    {/if}
                {else}
                    {if auth("$classuri/resume")}
                        <a data-update="{$vo.id}" data-field='app_status' data-value='1' data-action='{:url("$classuri/resume")}'
                           href="javascript:void(0)" style="color:#c00">已禁用</a>
                    {else}
                        <span style="color:#c00">已禁用</span>
                    {/if}
                {/if}
            </td>
            <td class='text-center'>{$vo.handler_name|default="<span style='color:#ccc'>暂无</span>"}</td>
            <td class='text-center nowrap'>
                {if auth("$classuri/edit")}
                <a data-modal='{:url("$classuri/edit")}?id={$vo.id}' data-title="编辑应用" href="javascript:void(0)">编辑</a>
                {/if}
                {if auth("$classuri/del")}
                <span class="text-explode">|</span>
                <a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}'
                   href="javascript:void(0)" style="color:#c00">删除</a>
                {/if}
            </td>
        </tr>
        {/foreach}
        {if empty($list)}
        <tr><td colspan="12" style="text-align:center">没 有 记 录 了 哦 !</td></tr>
        {/if}
        </tbody>
    </table>
    {if isset($page)}<p>{$page}</p>{/if}
</form>
{/block}